from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction

desired_caps = dict()
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = '192.168.56.101:5555'
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'

driver = webdriver.Remote('http://192.168.41.103:4723/wd/hub', desired_caps)

# 移动
TouchAction(driver).move_to(x=350, y=350).perform()


# 长按
# TouchAction(driver).long_press(x=350, y=350).perform()
# 等价于（上面和下面一个意思）
# TouchAction(driver).press(x=350, y=350).wait(1000).perform()

# 等待
# TouchAction(driver).press(x=350, y=350).wait(3000).release().perform()

# 按下和抬起
# TouchAction(driver).press(x=350, y=350).release().perform()

# 轻敲
# TouchAction(driver).tap().perform()

# wlan = driver.find_element_by_xpath("//*[@text='WLAN']")
# TouchAction(driver).tap(wlan, x=350, y=350).perform()